home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qslider.h.z / qslider.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.5 KB  |  141 lines

  1. /****************************************************************************
  2. ** $Id: qslider.h,v 2.24 1998/07/03 00:09:53 hanord Exp $
  3. **
  4. ** Definition of QSlider class
  5. **
  6. ** Created : 961019
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QSLIDER_H
  25. #define QSLIDER_H
  26.  
  27. #ifndef QT_H
  28. #include "qwidget.h"
  29. #include "qrangecontrol.h"
  30. #endif // QT_H
  31.  
  32.  
  33. class QTimer;
  34. struct QSliderData;
  35.  
  36.  
  37. class QSlider : public QWidget, public QRangeControl
  38. {
  39.     Q_OBJECT
  40. public:
  41.     enum Orientation { Horizontal, Vertical };
  42.     enum TickSetting { NoMarks = 0, Above = 1, Left = Above, 
  43.                Below = 2, Right = Below, Both = 3 };
  44.  
  45.     QSlider( QWidget *parent=0, const char *name=0 );
  46.     QSlider( Orientation, QWidget *parent=0, const char *name=0 );
  47.     QSlider( int minValue, int maxValue, int step, int value, Orientation,
  48.          QWidget *parent=0, const char *name=0 );
  49.  
  50.     void    setOrientation( Orientation );
  51.     Orientation orientation() const;
  52.     void    setTracking( bool enable );
  53.     bool    tracking() const;
  54.  
  55.     void     setPalette( const QPalette & );
  56.     QRect    sliderRect() const;
  57.     QSize    sizeHint() const;
  58.  
  59.     virtual void setTickmarks( TickSetting );
  60.     TickSetting tickmarks() const { return ticks; }
  61.  
  62.     virtual void setTickInterval( int );
  63.     int     tickInterval() const { return tickInt; }
  64.  
  65. public slots:
  66.     void    setValue( int );
  67.     void    addStep();
  68.     void    subtractStep();
  69.  
  70. signals:
  71.     void    valueChanged( int value );
  72.     void    sliderPressed();
  73.     void    sliderMoved( int value );
  74.     void    sliderReleased();
  75.  
  76. protected:
  77.     void    resizeEvent( QResizeEvent * );
  78.     void    paintEvent( QPaintEvent * );
  79.  
  80.     void    keyPressEvent( QKeyEvent * );
  81.     void    mousePressEvent( QMouseEvent * );
  82.     void    mouseReleaseEvent( QMouseEvent * );
  83.     void    mouseMoveEvent( QMouseEvent * );
  84.     void    focusInEvent( QFocusEvent *e );
  85.  
  86.     void    valueChange();
  87.     void    rangeChange();
  88.  
  89.     virtual void paintSlider( QPainter *, const QRect & );
  90.     void    drawWinGroove( QPainter *, QCOORD );
  91.     void    drawTicks( QPainter *, int, int, int=1 ) const;
  92.  
  93.     virtual int    thickness() const;
  94.  
  95. private slots:
  96.     void    repeatTimeout();
  97.  
  98. private:
  99.     enum State { Idle, Dragging, TimingUp, TimingDown };
  100.  
  101.     void    init();
  102.     int        positionFromValue( int ) const;
  103.     int        valueFromPosition( int ) const;
  104.     void    moveSlider( int );
  105.     void    reallyMoveSlider( int );
  106.     void    resetState();
  107.     int        slideLength() const;
  108.     int        available() const;
  109.     int        goodPart( const QPoint& ) const;
  110.     void    initTicks();
  111.  
  112.     QSliderData *extra;
  113.     QTimer    *timer;
  114.     QCOORD    sliderPos;
  115.     int        sliderVal;
  116.     QCOORD    clickOffset;
  117.     State    state;
  118.     bool    track;
  119.     QCOORD    tickOffset;
  120.     TickSetting    ticks;
  121.     int        tickInt;
  122.     Orientation orient;
  123.  
  124. private:    // Disabled copy constructor and operator=
  125.     QSlider( const QSlider & );
  126.     QSlider &operator=( const QSlider & );
  127. };
  128.  
  129. inline bool QSlider::tracking() const
  130. {
  131.     return track;
  132. }
  133.  
  134. inline QSlider::Orientation QSlider::orientation() const
  135. {
  136.     return orient;
  137. }
  138.  
  139.  
  140. #endif // QSLIDER_H
  141.